import java.util.Scanner;

public class demo05 {
    //奇怪的数列
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        StringBuilder str=new StringBuilder(sc.nextLine());
        int n=sc.nextInt();
        StringBuilder str1=new StringBuilder();
        for (int k = 0; k <= n; k++) {
            if(str.length()==1){
                str1=new StringBuilder("1"+str);
            }else {
                int count=1;
                for (int i = 0; i < str.length();) {
                    char ch=str.charAt(i);
                    count=1;
                    for (int j = i+1; j < str.length(); j++) {
                        if(ch==str.charAt(j)){
                            count++;
                        }else{
                            break;
                        }
                    }
                    str1.append(count);
                    str1.append(ch);
                    i+=count;
                }
                int len=str.length();
                for (int j = 0; j < len; j++) {
                    str1.deleteCharAt(0);
                }
            }
            str=new StringBuilder(str1);
        }
        System.out.println(str1);
    }
}
